#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/7/29 14:14
# @Author  : Fairy Huang
# @File    : errors.py
# @Project: LabCrawler

class CrawlerError(Exception):
    error_code = 1000
    log_message = "Houston, We've Got a Problem"

    def __init__(self, message=None):
        if message is not None:
            self.log_message = message

    def __str__(self):
        return "(%d: %s)" % (self.error_code, self.log_message)


class DBNotFoundError(CrawlerError):
    error_code = 1001
    log_message = "DB Object Not Found"


class RENotMatchError(CrawlerError):
    error_code = 1002
    log_message = "Regular Expression Not Matched"


class JsonDecodeError(CrawlerError):
    error_code = 1003
    log_message = "Could not decode JSON string"


class SiteLoginError(CrawlerError):
    error_code = 1004
    log_message = "Login to The Site Failed"


class YDMBalanceError(CrawlerError):
    error_code = 1005
    log_message = "Insufficient YDM Account Balance"


class YDMDecodeError(CrawlerError):
    error_code = 1006
    log_message = "YDM Can Not Decode This Captcha"


class CSSSelectorError(CrawlerError):
    error_code = 1007
    log_message = "Can Not Locate CSS Selector"